package main

import (
	"encoding/json"
	"flag"
	"fmt"
	"time"
	"virchow_poster/modules"
)

func main() {
	println("start ==================================================================== start")

	var data string
	var authDelete bool
	flag.StringVar(&data, "config", "{}", "海报配置信息")
	flag.StringVar(&data, "c", "{}", "海报配置信息")
	flag.BoolVar(&authDelete, "delete", false, "是否自动删除下载的资源")

	flag.Parse()

	var poster modules.Poster
	err := json.Unmarshal([]byte(data), &poster)
	if err != nil {
		fmt.Println("参数解析失败", err)
	}

	if authDelete {
		defer modules.DeleteDownloadFiles(poster.SavePath)
	}

	start_time := time.Now()
	defer func() {
		cost := time.Since(start_time)
		fmt.Println("生成海报耗时：", cost)
	}()
	modules.Draw(&poster)
}
